{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "Text provided under a Creative Commons Attribution license, CC-BY.  All code is made available under the FSF-approved BSD-3 license.  (c) Lorena A. Barba, Gilbert F. Forsyth 2017. Thanks to NSF for support via CAREER award #1149784."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[@LorenaABarba](https://twitter.com/LorenaABarba)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "12 steps to Navier–Stokes\n",
    "======\n",
    "***"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You should have completed Steps [1](./01_Step_1.ipynb) and [2](./02_Step_2.ipynb) before continuing. This Jupyter notebook continues the presentation of the **12 steps to Navier–Stokes**, the practical module taught in the interactive CFD class of [Prof. Lorena Barba](http://lorenabarba.com). "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step 3: Diffusion Equation in 1-D\n",
    "-----\n",
    "***"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The one-dimensional diffusion equation is:\n",
    "\n",
    "$$\\frac{\\partial u}{\\partial t}= \\nu \\frac{\\partial^2 u}{\\partial x^2}$$\n",
    "\n",
    "The first thing you should notice is that —unlike the previous two simple equations we have studied— this equation has a second-order derivative. We first need to learn what to do with it!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Discretizing $\\frac{\\partial ^2 u}{\\partial x^2}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The second-order derivative can be represented geometrically as the line tangent to the curve given by the first derivative.  We will discretize the second-order derivative with a Central Difference scheme: a combination of Forward Difference and Backward Difference of the first derivative.  Consider the Taylor expansion of $u_{i+1}$ and $u_{i-1}$ around $u_i$:\n",
    "\n",
    "$u_{i+1} = u_i + \\Delta x \\frac{\\partial u}{\\partial x}\\bigg|_i + \\frac{\\Delta x^2}{2} \\frac{\\partial ^2 u}{\\partial x^2}\\bigg|_i + \\frac{\\Delta x^3}{3!} \\frac{\\partial ^3 u}{\\partial x^3}\\bigg|_i + O(\\Delta x^4)$\n",
    "\n",
    "$u_{i-1} = u_i - \\Delta x \\frac{\\partial u}{\\partial x}\\bigg|_i + \\frac{\\Delta x^2}{2} \\frac{\\partial ^2 u}{\\partial x^2}\\bigg|_i - \\frac{\\Delta x^3}{3!} \\frac{\\partial ^3 u}{\\partial x^3}\\bigg|_i + O(\\Delta x^4)$\n",
    "\n",
    "If we add these two expansions, you can see that the odd-numbered derivative terms will cancel each other out.  If we neglect any terms of $O(\\Delta x^4)$ or higher (and really, those are very small), then we can rearrange the sum of these two expansions to solve for our second-derivative.  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$u_{i+1} + u_{i-1} = 2u_i+\\Delta x^2 \\frac{\\partial ^2 u}{\\partial x^2}\\bigg|_i + O(\\Delta x^4)$\n",
    "\n",
    "Then rearrange to solve for $\\frac{\\partial ^2 u}{\\partial x^2}\\bigg|_i$ and the result is:\n",
    "\n",
    "$$\\frac{\\partial ^2 u}{\\partial x^2}=\\frac{u_{i+1}-2u_{i}+u_{i-1}}{\\Delta x^2} + O(\\Delta x^2)$$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Back to Step 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can now write the discretized version of the diffusion equation in 1D:\n",
    "\n",
    "$$\\frac{u_{i}^{n+1}-u_{i}^{n}}{\\Delta t}=\\nu\\frac{u_{i+1}^{n}-2u_{i}^{n}+u_{i-1}^{n}}{\\Delta x^2}$$\n",
    "\n",
    "As before, we notice that once we have an initial condition, the only unknown is $u_{i}^{n+1}$, so we re-arrange the equation solving for our unknown:\n",
    "\n",
    "$$u_{i}^{n+1}=u_{i}^{n}+\\frac{\\nu\\Delta t}{\\Delta x^2}(u_{i+1}^{n}-2u_{i}^{n}+u_{i-1}^{n})$$\n",
    "\n",
    "The above discrete equation allows us to write a program to advance a solution in time. But we need an initial condition. Let's continue using our favorite: the hat function. So, at $t=0$, $u=2$ in the interval $0.5\\le x\\le 1$ and $u=1$ everywhere else. We are ready to number-crunch!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHVNJREFUeJzt3XmUVOWdxvHvjwYEVFARRVFgXAA3Ah4XFBJbBRFEEGRz\nyUQ4EzeSIVETo8kEJk7GLcElKhxccEkEBGRVFDV2AgKKsiqIgEYUAwxCRBAR6Hf+eBtB6KW6+1a9\n9956PufU6SrqWvU75e2nb72rOecQEZF0qhG6ABERyR6FvIhIiinkRURSTCEvIpJiCnkRkRRTyIuI\npFiFIW9mx5jZX83sPTNbYmb/WcZxD5rZCjNbaGZtoi9VREQqq2YGx+wEbnLOLTSzg4B3zGyGc+79\n3QeYWRfgeOfciWZ2NjACaJedkkVEJFMVXsk759Y65xaW3N8CLAOa7HNYD+DpkmPeBBqY2ZER1yoi\nIpVUqTZ5M2sOtAHe3OepJsAnez1ew/5/CEREJMcyDvmSpprxwOCSK3oREYm5TNrkMbOa+IB/xjk3\nuZRD1gDH7vX4mJJ/2/d1tFCOiEgVOOesKv9dplfyTwBLnXMPlPH8FODfAcysHfAv59y60g50zukW\n0W3IkCHBa0jTTZ+nPsu43qqjwit5M2sPXAUsMbMFgANuB5r5zHYjnXMvmllXM1sJbAUGVKsqERGJ\nRIUh75x7AyjI4LifRFKRiIhERjNeE6ywsDB0CamizzM6+izjw6rb3lOpNzNzuXw/EZE0MDNcljte\nRUQkgRTyIiIpltE4eZGqWLkSpk2D446Diy6COnVCVySSf3QlL5Favhx+/3to2xbat4clS+CPf4TG\njeGqq2DSJNi2LXSVIvlDHa9SbUuXwvjx/rZhA1x+OfTuDR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aLJUyXHPGhmK0omULXJRh1pkcFktPPM7F9mNr/k9psQdSaBmT1uZuv2+tZZ2jE6NzNQ0Wep\n87JyzOwYM/urmb1XMqn0P8s4rnLnp3Mu0hv+D8dKoBlQC1gItNrnmC7ACyX3zwbmRl1HWm4Zfp7n\nAVNC15qEG9ABaAMsLuN5nZvRfZY6Lyv3eTYG2pTcPwhYHkV2ZuNKPpPJUz2ApwGcc28CDUo6bGV/\nmXyeAOrUzoBzbhawqZxDdG5mKIPPEnReZsw5t9Y5t7Dk/hZgGfvPSar0+ZmNkM9k8tS+x6wp5Rjx\nMvk8Ac4p+fr2gpmdnJvSUknnZrR0XlaBmTXHf0t6c5+nKn1+an2ZdHgHaOqc+8rMugCT8MNYRULS\neVkFJRNJxwODS67oqyUbV/JrgKZ7PT6m5N/2PebYCo4Rr8LP0zm3xTn3Vcn96UAtMzssdyWmis7N\niOi8rLyShR3HA8845yaXckilz89shPy3k6fMrDZ+8tSUfY6ZAvw7fDuj9l/OuXVZqCUNKvw8926T\nM7Oz8ENjNU+hbEbZbcU6NyunzM9S52WVPAEsdc49UMbzlT4/I2+ucRlMnnLOvWhmXc1sJbAVGBB1\nHWmRyecJ9DazG4AdwDagX7iK483MngUKgYZmthoYAtRG52alVfRZovOyUsysPXAVsMTMFuBX970d\nP7KuyuenJkOJiKSYtv8TEUkxhbyISIop5EVEUkwhLyKSYgp5EZEUU8iLiKSYQl5EJMUU8iIiKfb/\nhmgVBC8IIcwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f274455a6a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy                 #loading our favorite library\n",
    "from matplotlib import pyplot    #and the useful plotting library\n",
    "%matplotlib inline\n",
    "\n",
    "nx = 41\n",
    "dx = 2 / (nx - 1)\n",
    "nt = 20    #the number of timesteps we want to calculate\n",
    "nu = 0.3   #the value of viscosity\n",
    "sigma = .2 #sigma is a parameter, we'll learn more about it later\n",
    "dt = sigma * dx**2 / nu #dt is defined using sigma ... more later!\n",
    "\n",
    "\n",
    "u = numpy.ones(nx)      #a numpy array with nx elements all equal to 1.\n",
    "u[int(.5 / dx):int(1 / dx + 1)] = 2  #setting u = 2 between 0.5 and 1 as per our I.C.s\n",
    "\n",
    "un = numpy.ones(nx) #our placeholder array, un, to advance the solution in time\n",
    "\n",
    "for n in range(nt):  #iterate through time\n",
    "    un = u.copy() ##copy the existing values of u into un\n",
    "    for i in range(1, nx - 1):\n",
    "        u[i] = un[i] + nu * dt / dx**2 * (un[i+1] - 2 * un[i] + un[i-1])\n",
    "        \n",
    "pyplot.plot(numpy.linspace(0, 2, nx), u);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Learn More"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For a careful walk-through of the discretization of the diffusion equation with finite differences (and all steps from 1 to 4), watch **Video Lesson 4** by Prof. Barba on YouTube."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz\nODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2Nj\nY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY//AABEIAWgB4AMBIgACEQED\nEQH/xAAaAAEAAwEBAQAAAAAAAAAAAAAAAQIDBAUG/8QAOBAAAgIBAwEFBgUDBAIDAAAAAAECAxEE\nEiExBRNBUXEUIjJhcoEjNJGhsRXB0UJS8PEz4SRik//EABYBAQEBAAAAAAAAAAAAAAAAAAABAv/E\nABcRAQEBAQAAAAAAAAAAAAAAAAABESH/2gAMAwEAAhEDEQA/APvwAAAK7knhtfqBYEEgAQM84AkE\nbl5r9SQA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HOMcZf\nUw9lb62yfGEadzxFbvdTzjzA0M/aK+/7nd7/AKft6mmDlnoYS7QhrN0lKCxtT4b6Zf2YHUAAJAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAJIJAAgk\nAAAB/9k=\n",
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"400\"\n",
       "            height=\"300\"\n",
       "            src=\"https://www.youtube.com/embed/y2WaK7_iMRI\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.YouTubeVideo at 0x7f2744542b38>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import YouTubeVideo\n",
    "YouTubeVideo('y2WaK7_iMRI')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>\n",
       "<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>\n",
       "<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>\n",
       "<style>\n",
       "    @font-face {\n",
       "        font-family: \"Computer Modern\";\n",
       "        src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n",
       "    }\n",
       "    div.cell{\n",
       "        width:800px;\n",
       "        margin-left:16% !important;\n",
       "        margin-right:auto;\n",
       "    }\n",
       "    h1 {\n",
       "        font-family: 'Alegreya Sans', sans-serif;\n",
       "    }\n",
       "    h2 {\n",
       "        font-family: 'Fenix', serif;\n",
       "    }\n",
       "    h3{\n",
       "\t\tfont-family: 'Fenix', serif;\n",
       "        margin-top:12px;\n",
       "        margin-bottom: 3px;\n",
       "       }\n",
       "\th4{\n",
       "\t\tfont-family: 'Fenix', serif;\n",
       "       }\n",
       "    h5 {\n",
       "        font-family: 'Alegreya Sans', sans-serif;\n",
       "    }\t   \n",
       "    div.text_cell_render{\n",
       "        font-family: 'Alegreya Sans',Computer Modern, \"Helvetica Neue\", Arial, Helvetica, Geneva, sans-serif;\n",
       "        line-height: 135%;\n",
       "        font-size: 120%;\n",
       "        width:600px;\n",
       "        margin-left:auto;\n",
       "        margin-right:auto;\n",
       "    }\n",
       "    .CodeMirror{\n",
       "            font-family: \"Source Code Pro\";\n",
       "\t\t\tfont-size: 90%;\n",
       "    }\n",
       "/*    .prompt{\n",
       "        display: None;\n",
       "    }*/\n",
       "    .text_cell_render h1 {\n",
       "        font-weight: 200;\n",
       "        font-size: 50pt;\n",
       "\t\tline-height: 100%;\n",
       "        color:#CD2305;\n",
       "        margin-bottom: 0.5em;\n",
       "        margin-top: 0.5em;\n",
       "        display: block;\n",
       "    }\t\n",
       "    .text_cell_render h5 {\n",
       "        font-weight: 300;\n",
       "        font-size: 16pt;\n",
       "        color: #CD2305;\n",
       "        font-style: italic;\n",
       "        margin-bottom: .5em;\n",
       "        margin-top: 0.5em;\n",
       "        display: block;\n",
       "    }\n",
       "    \n",
       "    .warning{\n",
       "        color: rgb( 240, 20, 20 )\n",
       "        }  \n",
       "</style>\n",
       "<script>\n",
       "    MathJax.Hub.Config({\n",
       "                        TeX: {\n",
       "                           extensions: [\"AMSmath.js\"]\n",
       "                           },\n",
       "                tex2jax: {\n",
       "                    inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
       "                    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
       "                },\n",
       "                displayAlign: 'center', // Change this to 'center' to center equations.\n",
       "                \"HTML-CSS\": {\n",
       "                    styles: {'.MathJax_Display': {\"margin\": 4}}\n",
       "                }\n",
       "        });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.core.display import HTML\n",
    "def css_styling():\n",
    "    styles = open(\"../styles/custom.css\", \"r\").read()\n",
    "    return HTML(styles)\n",
    "css_styling()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> (The cell above executes the style for this notebook.)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
